package com.ruoyi.web.controller.seal;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.SealImg;
import com.ruoyi.system.service.ISealImgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 印章图片Controller
 * 
 * @author ess
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/seal/img")
public class SealImgController extends BaseController
{
    @Autowired
    private ISealImgService sealImgService;

    /**
     * 查询印章图片列表
     */
    @PreAuthorize("@ss.hasPermi('seal:img:list')")
    @GetMapping("/list")
    public TableDataInfo list(SealImg sealImg)
    {
        startPage();
        List<SealImg> list = sealImgService.selectSealImgList(sealImg);
        return getDataTable(list);
    }

    /**
     * 导出印章图片列表
     */
    @PreAuthorize("@ss.hasPermi('seal:img:export')")
    @Log(title = "印章图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SealImg sealImg)
    {
        List<SealImg> list = sealImgService.selectSealImgList(sealImg);
        ExcelUtil<SealImg> util = new ExcelUtil<SealImg>(SealImg.class);
        return util.exportExcel(list, "印章图片数据");
    }

    /**
     * 获取印章图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('seal:img:query')")
    @GetMapping(value = "/{imgId}")
    public AjaxResult getInfo(@PathVariable("imgId") String imgId)
    {
        return AjaxResult.success(sealImgService.selectSealImgByImgId(imgId));
    }

    /**
     * 新增印章图片
     */
    @PreAuthorize("@ss.hasPermi('seal:img:add')")
    @Log(title = "印章图片", businessType = BusinessType.INSERT)
    @ApiOperation("新增制作申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "imgData", value = "图像base64数据", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "imgH", value = "高", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "imgW", value = "宽", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "imgType", value = "图像格式", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping
    public AjaxResult add(@RequestBody SealImg sealImg)
    {
        return toAjax(sealImgService.insertSealImg(sealImg));
    }

    /**
     * 修改印章图片
     */
    @PreAuthorize("@ss.hasPermi('seal:img:edit')")
    @Log(title = "印章图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SealImg sealImg)
    {
        return toAjax(sealImgService.updateSealImg(sealImg));
    }

    /**
     * 删除印章图片
     */
    @PreAuthorize("@ss.hasPermi('seal:img:remove')")
    @Log(title = "印章图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imgIds}")
    public AjaxResult remove(@PathVariable String[] imgIds)
    {
        return toAjax(sealImgService.deleteSealImgByImgIds(imgIds));
    }
}
